#!/usr/bin/env python

"""Some perfunctory nose tests, mostly to make sure I'm not breaking anything
as I work. Not terribly well-documented, since I think they're pretty self-explanatory"""

import nose
from interval import *

def test_interval_contains_value():
    a = Interval("(0, 1]")
    assert 0.5 in a
    assert 0 not in a
    assert 1 in a
    assert -1 not in a
    
def test_interval_constructors():
    a = Interval("(0, 1)")
    b = Interval(0, 1, False, False)
    assert a == b
    
    c = Interval(a)
    assert a == c
    assert b == c
    
def test_subintervals():
    a = Interval("(0, 1)")
    b = Interval("(0, 1]")
    c = Interval(a)
    d = Interval("(0, 10)")
    
    assert a in b
    assert not b in a
    assert c in a and a in c
    assert a in d
    assert not d in a
    
def test_conjunctions():
    a = Interval("(0, 10)")
    b = Interval("(5, 15)")
    c = Interval("[0, 5]")
    d = Interval("(10, 15)")
    
    assert a & b == Interval(5, 10, False, False)
    assert a & c == Interval(0, 5, False, True), str(a & c)
    assert a & d == Interval(5, 0, False, False)

    
nose.runmodule()